/**
 * 
 */
package ar.com.contable.ganancias.model;

import java.util.ArrayList;
import java.util.List;

import ar.com.contable.ganancias.rule.Rule;
import ar.com.contable.ganancias.rule.RuleTotals;
import ar.com.contable.ganancias.util.Utils;

/**
 * Year model
 * @author E420611
 *
 */
public class YearFolderModel {

	private int year;
	private String name = "";
	private String surname = "Cliente";
	private MonthModel[] months = new MonthModel[12];
	private List<CategoryStrutModel> categories = new ArrayList<CategoryStrutModel>();
	
	private List<Rule> rules = new ArrayList<Rule>();
	
	public List<Rule> getRules() {
		return rules;
	}

	public void setRules(List<Rule> rules) {
		this.rules = rules;
	}

	public YearFolderModel(String surname2, String name2) {
		this.setName(name2);
		this.setSurname(surname2);
		for (int i = 0; i < 12; i++) {
			months[i] = new MonthModel(Utils.getMonthCode(i));
		}		
	}

	/**
	 * @return the year
	 */
	public int getYear() {
		return year;
	}

	/**
	 * @param year the year to set
	 */
	public void setYear(int year) {
		this.year = year;
	}

	/**
	 * @return the name
	 */
	public String getName() {
		return name;
	}

	/**
	 * @param name the name to set
	 */
	public void setName(String name) {
		this.name = name;
	}

	/**
	 * @return the surname
	 */
	public String getSurname() {
		return surname;
	}

	/**
	 * @param surname the surname to set
	 */
	public void setSurname(String surname) {
		this.surname = surname;
	}

	/**
	 * @return the months
	 */
	public MonthModel[] getMonths() {
		return months;
	}

	/**
	 * @param months the months to set
	 */
	public void setMonths(MonthModel[] months) {
		this.months = months;
	}

	/**
	 * @return the categories
	 */
	public List<CategoryStrutModel> getCategories() {
		return categories;
	}

	/**
	 * @param categories the categories to set
	 */
	public void setCategories(List<CategoryStrutModel> categories) {
		this.categories = categories;
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		return surname + ", " + name ;
	}

	public void refresh() {
		List<Rule> rules = this.getRules();
		for (Rule ruleModel : rules) {
			ruleModel.setModel(this);
			ruleModel.apply();
		}
	}
	
//	public List<String> getCategories(){
//		List<String> result  = new ArrayList(this.months[0].getCategoriesNames());
//		return result;
//	}
//	
//	/**
//	 * Return all item names
//	 * @param categorie
//	 * @return
//	 */
//	public List<String> getItemNames(String categorie){		
//		List<String> result  = new ArrayList(this.months[0].getCategories().get(categorie).keySet());
//		return result;
//	}
}
